package at.falb.games.alcatraz.api.common;

import java.io.Serializable;
import java.sql.Timestamp;

public class PlayerUnit implements Serializable {

	private static final long serialVersionUID = 7914637265296700015L;

	/**
	 * The <code>clientId</code> is the client id, defined on login server
	 */
	private int clientId;

	/**
	 * The <code>clientName</code> is a general name,
	 * that the registration server defines.
	 */
	private String clientName;

	/**
	 * The <code>gameStatus</code> is an indicator of player. 
	 * If player is active then value is true, otherwise is value false.
	 */
	private boolean gameStatus;

	/**
	 * The <code>loginTime</code> is from timestamp determined value,
	 * that defines the sequence of logged players.
	 */
	private Timestamp loginTime;

	/**
	 * The <code>loginServer</code> is a indicator of player. 
	 * If player is active then value is true, otherwise is value false.
	 */
	private String loginServer;

	/**
	 * @param clientId
	 * @param clientName
	 * @param gameStatus
	 */
	public PlayerUnit(int clientId, Timestamp loginTime, String clientName, String loginServer) {
		super();
		this.setClientId(clientId);
		this.setClientName(clientName);
		this.setLoginTime(loginTime);
		this.setLoginServer(loginServer);
		this.setGameStatus(false);
	}

	// Getter and Setter ...

	/**
	 * @return the clientId
	 */
	public int getClientId() {
		return clientId;
	}

	/**
	 * @param clientId the clientId to set
	 */
	public void setClientId(int clientId) {
		this.clientId = clientId;
	}

	/**
	 * @return the clientName
	 */
	public String getClientName() {
		return clientName;
	}

	/**
	 * @param clientName the clientName to set
	 */
	public void setClientName(String clientName) {
		this.clientName = clientName;
	}

	/**
	 * @return the gameStatus
	 */
	public boolean isGameStatus() {
		return gameStatus;
	}

	/**
	 * @param gameStatus the gameStatus to set
	 */
	public void setGameStatus(boolean gameStatus) {
		this.gameStatus = gameStatus;
	}

	/**
	 * @return the loginTime
	 */
	public Timestamp getLoginTime() {
		return loginTime;
	}

	/**
	 * @param loginTime the loginTime to set
	 */
	public void setLoginTime(Timestamp loginTime) {
		this.loginTime = loginTime;
	}


	/**
	 * @return the loginServer
	 */
	public String getLoginServer() {
		return loginServer;
	}

	/**
	 * @param loginServer the loginServer to set
	 */
	public void setLoginServer(String loginServer) {
		this.loginServer = loginServer;
	}

    /**
     * Indicates whether some other object is "equal to" this one.
     *
     * @param   obj   the reference object with which to compare.
     * @return  <code>true</code> if this object is the same as the obj
     *          argument; <code>false</code> otherwise.
     */
    public boolean equals(Object obj) {
    	if (this == obj) return true;
    	if (!(obj instanceof PlayerUnit)) 
    		return false;
    	return this.clientId == ((PlayerUnit)obj).getClientId();
    }

    /**
     * This object is itself returned.
     *
     * @return  the string itself.
     */
    public String toString() {
    	return this.clientName+"["+this.clientId+"]";
    }


    
}
